<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>修改密码</title>

		<link href="../AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">

		<link href="../css/personal.css" rel="stylesheet" type="text/css">
		<link href="../css/stepstyle.css" rel="stylesheet" type="text/css">

		<script type="text/javascript" src="../js/jquery-1.11.2.min.js"></script>
		<script src="../AmazeUI-2.4.2/assets/js/amazeui.js"></script>
		<script type="text/javascript" src="../js/global.js"></script>
		<script type="text/javascript" src="../js/bootstrap/js/bootstrap.js"></script>
		<script src="../js/layer/layer.js"></script>

	</head>

	<body>
		
            <div class="nav-table">
					   <div class="long-title"><span class="all-goods">全部分类</span></div>
					   <div class="nav-cont">
							<ul>
							<li class="index"><a href="../index.html">首页</a></li>
							<li class="qc"><a href="text.html">推荐</a></li>
							<li class="qc"><a href="../home/search.html">搜索</a></li>
							<li class="qc"><a href="#">团购</a></li>
							<li class="qc last"><a href="about.html">我们</a></li>
						</ul>
						</div>
			</div>
			<b class="line"></b>
		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="am-cf am-padding">
						<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">修改密码</strong> / <small>Password</small></div>
					</div>
					<hr/>
					<!--进度条-->
					<div class="m-progress">
						<div class="m-progress-list">
							<span class="step-1 step">
                                <em class="u-progress-stage-bg"></em>
                                <i class="u-stage-icon-inner">1<em class="bg"></em></i>
                                <p class="stage-name">重置密码</p>
                            </span>
							<span class="step-2 step">
                                <em class="u-progress-stage-bg"></em>
                                <i class="u-stage-icon-inner">2<em class="bg"></em></i>
                                <p class="stage-name">完成</p>
                            </span>
							<span class="u-progress-placeholder"></span>
						</div>
						<div class="u-progress-bar total-steps-2">
							<div class="u-progress-bar-inner"></div>
						</div>
					</div>
					<form class="am-form am-form-horizontal">
						<div class="am-form-group">
							<label for="user-old-password" class="am-form-label">原密码</label>
							<div class="am-form-content">
								<input type="password" id="oldPwd"  name="oldPwd" placeholder="请输入原登录密码">
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-new-password" class="am-form-label">新密码</label>
							<div class="am-form-content">
								<input type="password" id="Pwd" name="Pwd" placeholder="由数字、字母组合">
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-confirm-password" class="am-form-label">确认密码</label>
							<div class="am-form-content">
								<input type="password" id="Pwd2" name="Pwd2" placeholder="请再次输入上面的密码">
							</div>
						</div>
						<div class="info-btn">
							<input type="button" value="保存修改" class="am-btn am-btn-danger" id="updateBtn" />
							<input type="button" value="返回" class="am-btn am-btn-danger " onclick="history.back();"  />
							
						</div>

					</form>

				</div>
				<!--底部-->
				<div class="footer">
					<div class="footer-hd">
						<p>
							
							<b>|</b>
							<a href="#">商城首页</a>
							<b>|</b>
							<a href="#">支付宝</a>
							<b>|</b>
							<a href="#">物流</a>
						</p>
					</div>
					<div class="footer-bd">
						<p>
							
							<a href="#">合作伙伴</a>
							<a href="#">联系我们</a>
							<a href="#">网站地图</a>
							<em>© 2015-2025 XXXXXX <a href="http://www.cssmoban.com/" target="_blank" title=""></a> - Collect from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></em>
						</p>
					</div>
				</div>
			</div>

			<aside class="menu">
				<ul>
					<li class="person active">
						<a href="person/index.html"><i class="am-icon-user"></i>个人中心</a>
					</li>
					<!--管理员界面-->
					<li class="person">
						<p><i class="am-icon-qq"></i>管理系统</p>
						<ul>
							<li> <a href="querygoods.html">商品管理</a></li>
							<li> <a href="queryorder.html">订单管理</a></li>		
							
						</ul>
					</li>
					<!--普通界面-->
					<li class="person">
						<p><i class="am-icon-newspaper-o"></i>个人资料</p>
						<ul>
							<li> <a href="information.html">个人信息</a></li>
							<li> <a href="safety.html">安全设置</a></li>
							<li> <a href="address.html">地址管理</a></li>
							
						</ul>
					</li>
					<li class="person">
						<p><i class="am-icon-balance-scale"></i>我的交易</p>
						<ul>
							<li><a href="order.html">订单管理</a></li>
							<li> <a href="change.html">退款售后</a></li>
							<li> <a href="comment.html">评价商品</a></li>
						</ul>
					</li>
					
					<li class="person">
						<p><i class="am-icon-tags"></i>我的收藏</p>
						<ul>
							<li> <a href="collection.html">收藏</a></li>
																		
						</ul>
					</li>
					<li class="person">
						<p><i class="am-icon-qrcode"></i>在线客服</p>
						<ul>
							<li> <a href="suggest.html">意见反馈</a></li>		
							<li> <a href="news.html">我的消息</a></li>
						</ul>
					</li>
					
				</ul>

			</aside>
		</div>
		<script>
			$(function() {

				//表单验证
				function checkForm() {

					var oldPwd = $('#oldPwd');
					var Pwd = $('#Pwd');
					var Pwd2 = $('#Pwd2');

					if (oldPwd.val() == '' || oldPwd.val().length > 12) {
						layer.msg('旧密码不能为空，且小于12位');
						oldPwd.focus();
						return false;
					}
					//判断旧密码是否正确(同步请求)
					var result ;
					
					$.ajax({
						type: "post",
						url: baseUrl + "/user/checkPwd",
						async: false,
						data :{Pwd : $('#oldPwd').val()},
						dataType :'text'
					})
					.done(function(data){
						result = data;
						
					})	
					.fail(function(){
						layer.msg('检查旧密码请求失败');
					});
					
					if(result == 'false'){
						layer.msg('旧密码不正确');
						oldPwd.focus();
						return false;
					}
						

					if (Pwd.val() == '' || Pwd.val().length > 12) {
						layer.msg('新密码不能为空，且小于12位');
						Pwd.focus();
						return false;
					}
					if (Pwd.val() != Pwd2.val()) {
						layer.msg('两次密码输入不一致');
						Pwd2.focus();
						return false;
					}

					return true;
				}

				//修改按钮单击事件回调
				$('#updateBtn').click(function() {

					//调用表单验证
					if (!checkForm())
						return;
					//ajax
					$.post(baseUrl + '/user/updatePwd', {
						Pwd: $('#Pwd').val()
					}, function() {
						layer.msg('修改密码成功，请重新登录');
						setTimeout(function() {
							window.top.location.href = baseUrl + '/login.html';
						}, 500);
					}).error(function() {
						layer.msg('修改密码请求失败');
					});
				});

			});
		</script>
	</body>

</html>